from django.conf.urls.defaults import patterns, include, url
from django.views.generic import DetailView, ListView
from exams.models import Exam, User, TakenExam
from django.contrib.auth.decorators import login_required
from django.conf import settings

urlpatterns = patterns('exams.views',

	#exam
	url(r'^$', 'index'),
	url(r'^(?P<pk>\d+)/$',
		login_required(DetailView.as_view(
			model=Exam,	
			template_name='exams/show.html'))),
	url(r'^(?P<pk>\d+)/result/$',
		login_required(DetailView.as_view(
			model=TakenExam,	
			template_name='exams/result.html')),
		name='exam_result'),
	url(r'^(?P<exam_id>\d+)/submit/$', 'submit'),
	url(r'^(?P<exam_id>\d+)/delete/$', 'delete'),
        url(r'^(?P<exam_id>\d+)/summary/$', 'summary'),

	#new exam
	url(r'^new/$', 'new'),
	url(r'^create/$', 'create'),

   # users
	url(r'^users/$', 
        ListView.as_view(
            queryset=User.objects.all(),
            template_name='users/index.html')),	
	url(r'^users/(?P<pk>\d+)/$',
        DetailView.as_view(
            model=User,
				context_object_name='myuser',
            template_name='users/detail.html')),

)
